package com.twu.biblioteca.user;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by mderaldo on 9/30/14.
 */
public class UserFormat {

    private String usernameFormat = "\\d{3}-\\d{4}";

    public boolean verifyUsernameFormat(String username) {
        Pattern pattern = Pattern.compile(usernameFormat);
        Matcher matcher = pattern.matcher(username);
        boolean isUserNameFormat = matcher.matches();
        if(!isUserNameFormat){
            throw new UserNameInvalidException();
        }
        return isUserNameFormat;
    }
}
